package com.zwim.core.message;

import com.zwim.common.LogIdUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;

import java.util.List;

/**
 *将字节解码为消息
 */
@Slf4j
public class ProtobufMessageDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in,
                          List<Object> list) throws Exception {
        String logId= LogIdUtil.createLogId();
        //MDC.put(,logId);
        log.debug("将字节解码为消息,{}",logId);
        //标记读索引，写索引可类比
        in.markReaderIndex();
    }
}
